package com.demo.sortcsv;

import com.demo.sortcsv.domain.CanDetailDongFeng;

import java.util.Comparator;

public class ComparatorByFuelPressure implements Comparator<CanDetailDongFeng> {

    /**
     * f1 - f2 即为升序
     */
    boolean isAscend;
    public ComparatorByFuelPressure(boolean isAscend){
        this.isAscend = isAscend;
    }
    @Override
    public int compare(CanDetailDongFeng f1, CanDetailDongFeng f2) {
        // 降序
        if(!isAscend){
            return f2.getFuelPressure() - f1.getFuelPressure();
        } else {
            return f1.getFuelPressure() - f2.getFuelPressure();
        }

    }

}
